//
//  TabbarViewController.m
//  dmao-customer
//
//  Created by macbook on 2017/10/18.
//  Copyright © 2017年 秦慕乔. All rights reserved.
//
#import "TabbarViewController.h"
#import "LineOnViewController.h"
#import "LineDownViewController.h"
#import "RankViewController.h"
#import "MineViewController.h"

@interface TabbarViewController ()

@end

@implementation TabbarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    //试图数组
    NSArray* controllerArr = @[@"LineOnViewController",@"LineDownViewController",@"RankViewController",@"MineViewController"];
    //标题数组
    NSArray* titleArr = @[@"线上",@"线下",@"排名",@"我的"];
    //图片数组
    NSArray* picArr = @[@"HomeLO",@"HomeLD",@"HomeRank",@"HomeMine"];
    
    NSMutableArray* array = [[NSMutableArray alloc]init];
    
    for(int i=0; i<picArr.count; i++)
    {
        Class cl=NSClassFromString(controllerArr[i]);
        
        UIViewController* controller = [[cl alloc]init];
        UINavigationController* nv = [[UINavigationController alloc]initWithRootViewController:controller];
        
        controller.title = titleArr[i];
        
        nv.tabBarItem.image = [[UIImage imageNamed:[NSString stringWithFormat:@"%@",picArr[i]]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        //设置选中时的图片
        nv.tabBarItem.selectedImage = [[UIImage imageNamed:[NSString stringWithFormat:@"%@Select",picArr[i]]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        //设置选中时字体的颜色(也可更改字体大小)
        [nv.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor redColor]} forState:UIControlStateSelected];
        
        [array addObject:nv];
        
    }
    self.viewControllers = array;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
